package com.yfqy.admin.domain.dto.product;

import com.yfqy.admin.constant.MyConstants;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
public class UpAndDownProduct {

    /**
     * id
     */
    @NotNull(message = "id不能为空")
    private Long id;

    /**
     * 状态(1上架，2下架)
     */
    private Byte status;

    // 在setter方法中校验
    public void setStatus(Byte status) {
        if (status != null && (status == MyConstants.BT1 || status == MyConstants.BT2)) {
            this.status = status;
        } else {
            throw new IllegalArgumentException("上下架状态不能为空，1-上架，2-下架");
        }
    }
}
